/*
 * TestGlobalSched.java
 *
 * Created on Streda, 2007, november 14, 7:59
 *
 */

import java.util.Collection;
import java.util.Vector;
import javax.swing.JFrame;
import logic.gridSimInterface.resource.ResourceCharacteristicExt;
import logic.gridSimInterface.user.GridletInfo;
import logic.schedulers.AbstractGlobalScheduling;
import logic.schedulers.ParametersDialog;
import logicTests.Dbg;

/**
 *
 * @author alvin
 */
public class TestGlobalSched implements AbstractGlobalScheduling {
    
    /**
     * Creates a new instance of TestGlobalSched
     */
    public TestGlobalSched() {
        Dbg.vypis("Konstruktor TestGlobalSched().");
    }

    public String getName() {
        return "Test global sch";
    }

    public int getIndex() {
        return 0;
    }

    public ParametersDialog getParamDialog() {
        return null;
    }

    public Object getParameters() {
        return null;
    }

    public void setParameters(Object parameters) {
    }

    public int findResource(GridletInfo task, Collection<ResourceCharacteristicExt> resources) {
        System.out.println("testGlobalSched.findResouerce");
        int result = -1;
        for (ResourceCharacteristicExt element : resources) {
            if(element.isSuitableResource(task)) {
                if (element.hasFreePE())
                    return element.getResourceID();
                else if (result == -1)
                    result = element.getResourceID();
            }
        }
        return result;
    }

    public Vector<Integer> findResources(Vector<GridletInfo> tasks, Collection<ResourceCharacteristicExt> resources) {
        int count = tasks.size();
        Vector<Integer> result = new Vector<Integer>(count);
        for (int i = 0; i < count; i++) {
            result.add(new Integer(findResource(tasks.get(i), resources)));
        }
        return result;
    }
    public Vector<String> getParametersText() {
        return null;
    }

    public void setParametersText(Vector<String> newValues) {
    }

    public void createParamDialog(JFrame owner) {
    }
    
}
